﻿using System;
using System.IO;

namespace Wei8808Cms.Utility
{
    public class EventsLog
    {
        public static readonly log4net.ILog Loginfo = log4net.LogManager.GetLogger("loginfo");   //选择<logger name="loginfo">的配置 

        public static readonly log4net.ILog Logerror = log4net.LogManager.GetLogger("logerror");   //选择<logger name="logerror">的配置 

        public static void SetConfig()
        {
            log4net.Config.XmlConfigurator.Configure();
        }

        public static void SetConfig(FileInfo configFile)
        {
            log4net.Config.XmlConfigurator.Configure(configFile);
        }

        public static void WriteLog(string info)
        {
            if (!Loginfo.IsInfoEnabled) return;
            Loginfo.Info(info);
            Loginfo.Logger.Repository.Shutdown();
        }

        public static void WriteLog(string info, Exception se)
        {
            if (!Logerror.IsErrorEnabled) return;
            Logerror.Error(info, se);
            Logerror.Logger.Repository.Shutdown();
        }

    }
}
